package com.liugui.iostream;

import java.io.File;

/**
 * @ClassName: PrintDirTree
 * @Author: liugui
 * @Date: 2020-11-06 11:12
 **/
public class PrintDirTree {
    public static void main(String[] args) {
        File file = new File("F:\\liugui\\Project\\java_basics\\src");
        printDirTree(file,"");
    }

    public static void printDirTree(File file, String s) {
        if (file.isDirectory()) {
            File[] files;
            System.out.println(s + file.getName());
            if ((files = file.listFiles()) != null) {
                s = s + "   ";
                for (File file1 : files) {
                    printDirTree(file1, s);
                }
            }
        } else {
            System.out.println(s + file.getName());
        }
    }
}
